<template>

      <div class="table_1">
      <el-form :data="dataForm">
      
        <el-collapse v-model="activeNames" accordion class="parentColl">
        <el-collapse-item 
        v-for="(item,index) in dataForm.houseList"
        :key="item.key"
        style="border-bottom: 1px solid #f0f0f0;padding: 10px;" :title="item.title" :name="item.num">
      <div class="table_title td_color">抵押物信息栏</div>
      <table class="table_wrap">
        <tbody>
          <tr>
            <td class="table_td td_color">
                房产类型
            </td>
            <td class="table_td">
              <DicSelect dictType = "房产类型" :dictValue="item.estateType" v-on:dictValue="item.estateType = $event"/>
            </td>
            <td class="table_td td_color">
                共有情况
            </td>
            <td class="table_td">
              <DicSelect dictType = "共有情况" :dictValue="item.ownedSituation" v-on:dictValue="item.ownedSituation = $event"/>
            </td>
            <td class="table_td td_color">
                  获取方式
            </td>
            <td class="table_td">
              <DicSelect dictType = "获取方式" :dictValue="item.accessType" v-on:dictValue="item.accessType = $event"/>
            </td>
            <td class="table_td td_color">
                 小区名称
            </td>
            <td colspan="3" class="table_td">
            <el-input  v-model="item.villageName"/> 
            </td>
            <td class="table_td td_color">
                楼幢号
            </td>
            <td class="table_td">
            <el-input  v-model="item.buildNo"/> 
            </td>
          </tr>
          <!--第二行-->
          <tr>
            <td class="table_td td_color">
                总楼层数
            </td>
            <td class="table_td">
            <el-input  v-model="item.floorsTotal"/> 
            </td>
            <td class="table_td td_color">
                门牌号
            </td>
            <td class="table_td">
            <el-input  v-model="item.doorNo"/> 
            </td>
            <td class="table_td td_color">
                抵押物现状
            </td>
            <td class="table_td">
              <DicSelect dictType = "抵押物现状" :dictValue="item.currentSituation" v-on:dictValue="item.currentSituation = $event"/>
            </td>
            <td class="table_td td_color">
                 房龄  
            </td>
            <td class="table_td">
            <el-input  v-model="item.houseAge"/> 
            </td>
            <td class="table_td td_color">
                 产权人
            </td>
            <td class="table_td">
            <el-input  v-model="item.propertyOwner"/> 
            </td>
            <td class="table_td td_color">
                权利(土地)性质
            </td>
            <td class="table_td">
              <DicSelect dictType = "土地权利性质" :dictValue="item.landNature" v-on:dictValue="item.landNature = $event"/>
            </td>
          </tr>
          <!--第三行-->
          <tr>
            <td class="table_td td_color">
                房屋用途
            </td>
            <td class="table_td">
              <DicSelect dictType = "房屋用途" :dictValue="item.houseUse" v-on:dictValue="item.houseUse = $event"/>
            </td>
            <td class="table_td td_color">
                土地使用期限
            </td>
            <td class="table_td">
            <el-input  v-model="item.durationLandUse"/> 
            </td>
            <td class="table_td td_color">
                建筑面积
            </td>
            <td class="table_td">
            <el-input  v-model="item.areaTotal"/> 
            </td>
            <td class="table_td td_color">
                 楼层数  
            </td>
            <td class="table_td">
            <el-input  v-model="item.floors"/> 
            </td>
            <td class="table_td td_color">
                 不动产单元号
            </td>
            <td colspan="3" class="table_td">
            <el-input  v-model="item.unitNumber"/> 
            </td>
          </tr>
          <!--第四行-->
          <tr>
            <td class="table_td td_color">
                持证时间
            </td>
            <td class="table_td">
              <!-- <DicSelect dictType = "住宅类型" :dictValue="item.houseType" v-on:dictValue="item.houseType = $event"/> -->
              <el-date-picker
                v-model="item.licenseTime"
                type="date"
                value-format="yyyy-MM-dd"
                :picker-options="pickerOption"
                placeholder="选择日期"
                style="width:100%;"
              >
              </el-date-picker>
            </td>
            <td class="table_td td_color">
                房屋朝向
            </td>
            <td class="table_td">
              <DicSelect dictType = "房屋朝向" :dictValue="item.buildingHead" v-on:dictValue="item.buildingHead = $event"/>
            </td>
            <td class="table_td td_color">
                 房屋地址  
            </td>
            <td colspan="3" class="table_td">
             <el-cascader v-model="item.addressRegionValues" :options="regionList" clearable  placeholder="请选择地址" 
             :props="{ expandTrigger: 'hover' }" style="width:100%;"></el-cascader>
            </td>
            <td class="table_td td_color">
              房屋详细地址
            </td>
            <td colspan="3"  class="table_td">
              <el-input  v-model="item.addressDetail"/> 
            </td>
          </tr>
          <!--第五行-->
          <tr>
            <td class="table_td td_color">
                产证号
            </td>
            <td colspan="3" class="table_td">
              <el-input  v-model="item.licenseNo"/> 
            </td>
            <td class="table_td td_color" >
                现使用情况
            </td>
            <td colspan="1" class="table_td">
              <DicSelect dictType = "现使用情况" :dictValue="item.nowUsage" v-on:dictValue="item.nowUsage = $event"/>
            </td>
<!--             <td class="table_td td_color" colspan="2">
                权利(土地)性质
            </td>
            <td colspan="1" class="table_td">
             <DicSelect dictType = "土地权利性质" :dictValue="item.landNature" v-on:dictValue="item.houseDTO.landNature = $event"/>
            </td> -->
            <td class="table_td td_color" colspan="2">
                权利(房产)性质
            </td>
            <td colspan="1" class="table_td">
             <el-input v-model="item.houseNature" maxlength="10"/>
            </td>
<!--             <td class="table_td td_color">
                抵押现状
            </td>
            <td colspan="1" class="table_td">
             <DicSelect dictType = "抵押物现状" :dictValue="dataForm.currentSituation" v-on:dictValue="dataForm.houseDTO.currentSituation = $event"/>
            </td> -->
          </tr>

        </tbody>
      </table>

  <!--第二个表格-->
        
        <div class="table_title td_color" style="margin-top:30px;">现房抵押情况</div>
         <table class="table_wrap">
        <tbody>
          <!--第二行-->
          <tr v-for="items in item.houseHistries">
            <td class="table_td td_color">
                {{items.title}}
            </td>
            <td colspan="2"  class="table_td">
            <!-- <el-input  v-model="item.borrowerOrg"/>  -->
              <DicSelect dictType = "借款机构" :dictValue="items.borrowerOrgType" v-on:dictValue="items.borrowerOrgType = $event"/>
            </td>
            <td class="table_td td_color">
                借款类型
            </td>
            <td class="table_td">
            <DicSelect dictType = "借款类型" :dictValue="items.loanType" v-on:dictValue="items.loanType = $event"/>
            </td>
            <td class="table_td td_color">
                借款金额
            </td>
            <td class="table_td">
            <el-input  v-model="items.money"/> 
            </td>
            <td class="table_td td_color">
                期限
            </td>
            <td class="table_td">
            <el-input v-model="items.deadline"/> 
            </td>
            <td class="table_td td_color">
                 剩余本金
            </td>
            <td class="table_td">
            <el-input type="number" v-model="items.remainCapital"/> 
            </td>
            <td class="table_td td_color">
                还款方式
            </td>
            <td colspan="2" class="table_td">
            <el-input v-model="items.repayWay"/> 
            </td>
          </tr>
        

        </tbody>
          </table>

          <div class="table_1" v-if="showEvaluation" style="margin-top:30px;">
            <div class="table_title td_color">房屋评估信息</div>
             <table class="table_wrap">
            <tbody>
              <!--第一行-->
              <tr>
                <td class="table_td td_color">
                  世联评估(万元)
                </td>
                <td colspan="2"  class="table_td">
                  <el-input v-model="item.editForm.slEvaluationPrice" @change="value => inputChange(value,'slEvaluationPrice',index)" @input="numValid('slEvaluationPrice',index)" placeholder="评估后自动填充价格">
                      <template slot="append"><el-button @click="clickGet(index)" v-loading.fullscreen.lock="fullscreenLoading">评估</el-button></template>
                    </el-input>
                </td>
                <td class="table_td " colspan="8">
                    
                </td>
              </tr>
              <!-- 第二行 -->
              <tr>
                <td class="table_td td_color">
                  蓝海APP(万元)
                </td>
                <td colspan="2"  class="table_td">
                  <el-input v-model="item.editForm.lanhaiEvaluationPrice" @change="value => inputChange(value,'lanhaiRate',index)" @input="numValid('lanhaiEvaluationPrice',index)" placeholder="请输入评估价格">
                      <template slot="append">同比世联 {{(item.editForm.lanhaiRate) && item.editForm.lanhaiEvaluationPrice != ''?item.editForm.lanhaiRate < 0?item.editForm.lanhaiRate.toString().replace(/-/g,"")+'%':item.editForm.lanhaiRate+'%':item.editForm.lanhaiRate == 0?"0%":'-'}} <span v-if="item.editForm.lanhaiRate > 0" style="color:#ff0000;">↑</span> <span v-if="item.editForm.lanhaiRate < 0" style="color:#00b050;">↓</span></template>
                    </el-input>
                </td>
                <td class="table_td td_color">
                  国厚评估(万元)
                </td>
                <td colspan="2"  class="table_td">
                  <el-input v-model="item.editForm.guohouEvaluationPrice" @change="value => inputChange(value,'guohouRate',index)"  @input="numValid('guohouEvaluationPrice',index)" placeholder="请输入评估价格">
                      <template slot="append">同比世联 {{(item.editForm.guohouRate) && item.editForm.guohouEvaluationPrice != ''?item.editForm.guohouRate < 0?item.editForm.guohouRate.toString().replace(/-/g,"")+'%':item.editForm.guohouRate+'%':item.editForm.guohouRate == 0?"0%":'-'}} <span v-if="item.editForm.guohouRate > 0" style="color:#ff0000;">↑</span> <span v-if="item.editForm.guohouRate < 0" style="color:#00b050;">↓</span></template>
                    </el-input>
                </td>
                <td class="table_td td_color">
                  小亿评估(万元)
                </td>
                <td colspan="2"  class="table_td">
                  <el-input v-model="item.editForm.xiaoyiEvaluationPrice" @change="value => inputChange(value,'xiaoyiRate',index)" @input="numValid('xiaoyiEvaluationPrice',index)" placeholder="请输入评估价格">
                      <template slot="append">同比世联 {{(item.editForm.xiaoyiRate) && item.editForm.xiaoyiEvaluationPrice != ''?item.editForm.xiaoyiRate < 0 ? item.editForm.xiaoyiRate.toString().replace(/-/g,"")+'%':item.editForm.xiaoyiRate+'%':item.editForm.xiaoyiRate == 0?"0%":'-'}} <span v-if="item.editForm.xiaoyiRate > 0" style="color:#ff0000;">↑</span> <span v-if="item.editForm.xiaoyiRate < 0" style="color:#00b050;">↓</span></template>
                    </el-input>
                </td>
              </tr>
              <!-- 第三行 -->
              <tr>
                <td class="table_td td_color">
                  亚联财评估(万元)
                </td>
                <td colspan="2"  class="table_td">
                  <el-input v-model="item.editForm.yaliancaiEvaluationPrice" @change="value => inputChange(value,'yaliancaiRate',index)" @input="numValid('yaliancaiEvaluationPrice',index)" placeholder="请输入评估价格">
                      <template slot="append">同比世联 {{(item.editForm.yaliancaiRate) && item.editForm.yaliancaiEvaluationPrice != ''?item.editForm.yaliancaiRate<0 ? item.editForm.yaliancaiRate.toString().replace(/-/g,"")+'%':item.editForm.yaliancaiRate+'%':item.editForm.yaliancaiRate == 0?"0%":'-'}} <span v-if="item.editForm.yaliancaiRate > 0" style="color:#ff0000;">↑</span> <span v-if="item.editForm.yaliancaiRate < 0" style="color:#00b050;">↓</span></template>
                    </el-input>
                </td>
                <td class="table_td td_color">
                  中关村评估(万元)
                </td>
                <td colspan="2"  class="table_td">
                  <el-input v-model="item.editForm.zhongguancunEvaluationPrice" @change="value => inputChange(value,'zhongguancunRate',index)" @input="numValid('zhongguancunEvaluationPrice',index)" placeholder="请输入评估价格">
                      <template slot="append">同比世联 {{(item.editForm.zhongguancunRate) && item.editForm.zhongguancunEvaluationPrice != ''?item.editForm.zhongguancunRate<0 ? item.editForm.zhongguancunRate.toString().replace(/-/g,"")+'%':item.editForm.zhongguancunRate+'%':item.editForm.zhongguancunRate == 0?"0%":'-'}} <span v-if="item.editForm.zhongguancunRate > 0" style="color:#ff0000;">↑</span> <span v-if="item.editForm.zhongguancunRate < 0" style="color:#00b050;">↓</span></template>
                    </el-input>
                </td>
                <td class="table_td td_color">
                  其他机构(万元)
                </td>
                <td colspan="2"  class="table_td">
                  <el-input v-model="item.editForm.otherEvaluationPrice" @change="value => inputChange(value,'otherRate',index)" @input="numValid('otherEvaluationPrice',index)" placeholder="请输入评估价格">
                      <template slot="append">同比世联 {{(item.editForm.otherRate) && item.editForm.otherEvaluationPrice != ''?item.editForm.otherRate < 0 ? item.editForm.otherRate.toString().replace(/-/g,"")+'%':item.editForm.otherRate+'%':item.editForm.otherRate == 0?"0%":'-'}} <span v-if="item.editForm.otherRate > 0" style="color:#ff0000;">↑</span> <span v-if="item.editForm.otherRate < 0" style="color:#00b050;">↓</span></template>
                    </el-input>
                </td>
              </tr>
              
              <!-- 第四行 -->
              <tr>
                <td class="table_td td_color">
                  房产评估总价(终审)
                </td>
                <td colspan="2"  class="table_td">
                  <el-input v-model="item.editForm.finalReviewEvaluationPrice" placeholder="请输入评估价格" @input="numValid('finalReviewEvaluationPrice',index)" >
                      <template slot="append">万元</template>
                    </el-input>
                </td>
                <td class="table_td td_color">
                  房产剩余价值
                </td>
                <td colspan="2"  class="table_td">
                  <el-input v-model="item.remainValue" placeholder="请输入评估价格" @input="numValiddata('remainValue',index)" >
                      <template slot="append">万元</template>
                    </el-input>
                </td>
                <td class="table_td td_color">
                  
                </td>
                <td colspan="2"  class="table_td">
                  
                </td>
              </tr>
            </tbody>
          </table>

          </div>
        </el-collapse-item>
        </el-collapse>
      </el-form>
      
      
        <!-- <el-card class="box-card" shadow="never">
         <el-form ref="item.editForm" :inline="true" :model="editForm" status-icon label-position="right" label-width="160px" >
        
                  <el-form-item label="房产评估核查" prop="slEvaluationPrice">
                      <el-cascader
                      v-model="regionValues"
                      :options="regionList"
                      clearable 
                      placeholder="请选择房产所在区域"
                      :props="{ expandTrigger: 'hover' }" 
                      style="width:100%;"></el-cascader>
                   
                  </el-form-item>
                   <el-form-item label="折扣率" prop="rate" >
                    <el-input type="number"  v-model="editForm.rate"  placeholder="请输入折扣率">
                      <template slot="append">%</template>
                    </el-input>
                  </el-form-item>
                   <el-form-item label="房产详细地址" prop="rate" >
                    <el-input v-model="editForm.address"  placeholder="请输入房产详细地址">
                    </el-input>
                  </el-form-item>
                   <el-form-item label="房产价格（万元）" prop="rate" >
                    <el-input v-model="editForm.slEvaluationPrice" placeholder="评估后自动填充房产价格">
                       <template slot="append"><el-button @click="clickGet" v-loading.fullscreen.lock="fullscreenLoading">评估</el-button></template>
                    </el-input>
                  </el-form-item>
              
          
           </el-form>
      </el-card> -->

      <div class="table_1" style="margin-top:30px;">
        <div class="table_title td_color">调查情况说明</div>
         <table class="table_wrap">
          <tbody>
            <tr>
              <td class="table_td td_color">
                <el-input type="textarea" placeholder="请输入调查情况说明"
                  maxlength="200"
                  rows="5"
                  show-word-limit
                  v-model="dataForm.investigatorDesc"
                />
              </td>
            </tr>
          </tbody>
         </table>
      </div>
      <!---->
       <div style="width:400px;margin-top:5%;margin-left:40%;">
         <!-- v-permission="'system:check-opinion:print'" -->
              <!-- <el-button  type="primary" @click="restForm" v-permission="'system:check-opinion:edit'" style="width:150px;height:40px;">清空</el-button> -->
              <el-button  v-if="operationLook === undefined" v-permission="'system:house:edit'"  type="warning" @click="createData" style="width:150px;height:40px;">保存</el-button>
              <el-button  v-permission="'system:house:print'" type="primary" @click="exportData" style="width:150px;height:40px;">打印</el-button>
          </div>
    </div>


    
 

</template>

<script>
import { findByProjectId,updateHouseRate,houseEvaluation,updateHouse,exportHouse } from '@/api/house'
import { taskSupplementStatus } from '@/api/project'
import {capitalMatch} from "@/api/projectFile"
import { listRegion } from '@/api/region'
import DicSelect from '@/components/select'
  export default {
    components: { DicSelect },
      // 接受父组件的值
      props: {
        changeValue: undefined,
        projectId: undefined,
        operationLook: undefined,
        taskId: undefined,
        projectStatus: undefined
    },
    data () {
      return {
         addressRegionValues: [],
         regionValues: [],
         headData: "",
         activeNames:"1",
         dataForm:{
           houseList:[]
         },
         editForm:[],
         address: undefined,
         regionList:[],
         showEvaluation: true,
         fullscreenLoading: false,
          pickerOption: {
            disabledDate(current) {
              return current && current.getTime() > new Date().getTime();
            }
          },
      }
    },
    created(){
      this.findByProjectId()
      this.getRegionList()
      if( this.projectStatus === 18){
        this.taskSupplementStatus()
      }
    },
    methods: {
       findByProjectId() {
      this.listLoading = true
      findByProjectId({projectId:this.projectId})
        .then(response => {
          if(response.data != undefined ) {
            this.addressRegionValues = []
            let addressRegionValues = []
            let regionValues = []
            let editForm = {}
            response.data.map((item,index) => {
              // addressRegionValues.push(item.provinceId)
              // addressRegionValues.push(item.cityId)
              // addressRegionValues.push(item.areaId)
              addressRegionValues = [item.provinceId,item.cityId,item.areaId]
              if( item.provinceId!=undefined) {
                // regionValues.push(item.provinceId)
                // regionValues.push(item.cityId)
                // regionValues.push(item.areaId)
                  regionValues = [item.provinceId,item.cityId,item.areaId]
                }
              let data = {
                 id:item.houseEvaluateDTO.id,
                createId: item.createId,
                houseId:item.houseEvaluateDTO.houseId,
                slEvaluationPrice: item.houseEvaluateDTO.slEvaluationPrice,
                lanhaiEvaluationPrice: item.houseEvaluateDTO.lanhaiEvaluationPrice,
                lanhaiRate:item.houseEvaluateDTO.lanhaiRate,
                guohouEvaluationPrice: item.houseEvaluateDTO.guohouEvaluationPrice,
                guohouRate:item.houseEvaluateDTO.guohouRate,
                xiaoyiEvaluationPrice: item.houseEvaluateDTO.xiaoyiEvaluationPrice,
                xiaoyiRate:item.houseEvaluateDTO.xiaoyiRate,
                yaliancaiEvaluationPrice: item.houseEvaluateDTO.yaliancaiEvaluationPrice,
                yaliancaiRate:item.houseEvaluateDTO.yaliancaiRate,
                zhongguancunEvaluationPrice: item.houseEvaluateDTO.zhongguancunEvaluationPrice,
                zhongguancunRate:item.houseEvaluateDTO.zhongguancunRate,
                otherEvaluationPrice: item.houseEvaluateDTO.otherEvaluationPrice,
                otherRate:item.houseEvaluateDTO.otherRate,
                finalReviewEvaluationPrice:item.houseEvaluateDTO.finalReviewEvaluationPrice,
                // remainValue:item.houseEvaluateDTO.remainValue,
                deleted: item.houseEvaluateDTO.deleted
              }
              item.editForm = data
              item.addressRegionValues = addressRegionValues
              item.regionValues = regionValues
              item.title = "房产信息栏"+(index+1)
              item.num = (index+1)+""
              if(item.houseHistries) {
                 item.houseHistries.map((items,indexs) => {
                  items.title = this.getValue(indexs+1)+"押借款机构"
                });
              }
              
            })
            this.dataForm.houseList = response.data
            
          //  this.activeNames = this.dataForm.houseList.length+""
            // this.addressRegionValues.push(this.dataForm.provinceId)
            // this.addressRegionValues.push(this.dataForm.cityId)
            // this.addressRegionValues.push(this.dataForm.areaId)
            // this.editForm = {
            //   id:this.dataForm.houseEvaluateDTO.id,
            //   createId: this.dataForm.createId,
            //   houseId:this.dataForm.houseEvaluateDTO.houseId,
            //   slEvaluationPrice: this.dataForm.houseEvaluateDTO.slEvaluationPrice,
            //   lanhaiEvaluationPrice: this.dataForm.houseEvaluateDTO.lanhaiEvaluationPrice,
            //   lanhaiRate:this.dataForm.houseEvaluateDTO.lanhaiRate,
            //   guohouEvaluationPrice: this.dataForm.houseEvaluateDTO.guohouEvaluationPrice,
            //   guohouRate:this.dataForm.houseEvaluateDTO.guohouRate,
            //   xiaoyiEvaluationPrice: this.dataForm.houseEvaluateDTO.xiaoyiEvaluationPrice,
            //   xiaoyiRate:this.dataForm.houseEvaluateDTO.xiaoyiRate,
            //   yaliancaiEvaluationPrice: this.dataForm.houseEvaluateDTO.yaliancaiEvaluationPrice,
            //   yaliancaiRate:this.dataForm.houseEvaluateDTO.yaliancaiRate,
            //   zhongguancunEvaluationPrice: this.dataForm.houseEvaluateDTO.zhongguancunEvaluationPrice,
            //   zhongguancunRate:this.dataForm.houseEvaluateDTO.zhongguancunRate,
            //   otherEvaluationPrice: this.dataForm.houseEvaluateDTO.otherEvaluationPrice,
            //   otherRate:this.dataForm.houseEvaluateDTO.otherRate,
            //   finalReviewEvaluationPrice:this.dataForm.houseEvaluateDTO.finalReviewEvaluationPrice,
            //   // remainValue:this.dataForm.remainValue,
            //   deleted: this.dataForm.houseEvaluateDTO.deleted

            // }
            // this.regionValues = []
            // if( this.dataForm.provinceId!=undefined) {
            // this.regionValues.push(this.dataForm.provinceId)
            // this.regionValues.push(this.dataForm.cityId)
            // this.regionValues.push(this.dataForm.areaId)
            // }
            console.log(this.dataForm.houseList)
           
          }
        })
        .catch((e) => {
          console.log(e)
        })
    },
   getValue(val){
      if(val === 1) {
        return "一";
      }
      if(val == 2) {
        return "二";
      }
      if(val == 3) {
        return "三";
      }
    },
    getRegionList() {
      listRegion()
        .then(response => {
          if(response.data != undefined ) {
            this.regionList = response.data
            
            
          }
        })
        .catch(() => {
        })
    },
    houseEvaluation(index) {
      const loading = this.$loading({
          lock: true,
          text: '评估中',
          spinner: 'el-icon-loading',
          background: 'rgba(192, 192, 192, 0.7)'
        });
      houseEvaluation({address:this.dataForm.houseList[index].addressDetail,buildArea: this.dataForm.houseList[index].areaTotal,
      projectId: this.projectId,houseId: this.dataForm.houseList[index].id,provinceId: this.dataForm.houseList[index].addressRegionValues[0], cityId: this.dataForm.houseList[index].addressRegionValues[1],areaId: this.dataForm.houseList[index].addressRegionValues[2]})
        .then(response => {
          if(response.data != undefined ) {
               loading.close();
               this.dataForm.houseList[index].editForm.slEvaluationPrice = response.data
               this.$notify.success({
                title: '成功',
                message: '评估成功'
              })
              let slEvaluationPrice = this.dataForm.houseList[index].editForm.slEvaluationPrice
              if(this.dataForm.houseList[index].editForm.lanhaiEvaluationPrice != "" || this.dataForm.houseList[index].editForm.lanhaiEvaluationPrice != undefined ) {
                  let tb = (this.dataForm.houseList[index].editForm.lanhaiEvaluationPrice - slEvaluationPrice)/slEvaluationPrice*100;
                // tb = !isNaN(tb) && tb<0?Number(tb.toString().replace(/-/g,'')):tb;
                  this.dataForm.houseList[index].editForm.lanhaiRate = !isNaN(tb)?tb.toFixed(2):'';
                }
                //国厚
                if(this.dataForm.houseList[index].editForm.guohouEvaluationPrice != "" || this.dataForm.houseList[index].editForm.guohouEvaluationPrice  != undefined ) {
                  let tb = (this.dataForm.houseList[index].editForm.guohouEvaluationPrice - slEvaluationPrice)/slEvaluationPrice*100;
                // tb = !isNaN(tb) && tb<0?Number(tb.toString().replace(/-/g,'')):tb;
                  this.dataForm.houseList[index].editForm.guohouRate = !isNaN(tb)?tb.toFixed(2):'';
                  
                }
                //小忆
                if(this.dataForm.houseList[index].editForm.xiaoyiEvaluationPrice != "" || this.dataForm.houseList[index].editForm.xiaoyiEvaluationPrice != undefined ) {
                  let tb = (this.dataForm.houseList[index].editForm.xiaoyiEvaluationPrice - slEvaluationPrice)/slEvaluationPrice*100;
                // tb = !isNaN(tb) && tb<0?Number(tb.toString().replace(/-/g,'')):tb;
                  this.dataForm.houseList[index].editForm.xiaoyiRate = !isNaN(tb)?tb.toFixed(2):'';
                }
                //亚联财
                if(this.dataForm.houseList[index].editForm.yaliancaiEvaluationPrice != "" || this.dataForm.houseList[index].editForm.yaliancaiEvaluationPrice != undefined ) {
                  let tb = (this.dataForm.houseList[index].editForm.yaliancaiEvaluationPrice - slEvaluationPrice)/slEvaluationPrice*100;
                // tb = !isNaN(tb) && tb<0?Number(tb.toString().replace(/-/g,'')):tb;
                  this.dataForm.houseList[index].editForm.yaliancaiRate = !isNaN(tb)?tb.toFixed(2):'';
                }
                //中关村
                if(this.dataForm.houseList[index].editForm.zhongguancunEvaluationPrice != "" || this.dataForm.houseList[index].editForm.zhongguancunEvaluationPrice != undefined ) {
                  let tb = (this.dataForm.houseList[index].editForm.zhongguancunEvaluationPrice - slEvaluationPrice)/slEvaluationPrice*100;
                // tb = !isNaN(tb) && tb<0?Number(tb.toString().replace(/-/g,'')):tb;
                  this.dataForm.houseList[index].editForm.zhongguancunRate = !isNaN(tb)?tb.toFixed(2):'';
                }
                //其他
                if(this.dataForm.houseList[index].editForm.otherEvaluationPrice != "" || this.dataForm.houseList[index].editForm.otherEvaluationPrice != undefined ) {
                  let tb = (this.dataForm.houseList[index].editForm.otherEvaluationPrice - slEvaluationPrice)/slEvaluationPrice*100;
                // tb = !isNaN(tb) && tb<0?Number(tb.toString().replace(/-/g,'')):tb;
                  this.dataForm.houseList[index].editForm.otherRate = !isNaN(tb)?tb.toFixed(2):'';
                }
                this.$forceUpdate()
          }
        })
        .catch(() => {
          loading.close();
        })
    },
     taskSupplementStatus() {
      taskSupplementStatus({projectId:this.projectId,taskId: this.taskId})
        .then(response => {
          if( this.projectStatus < 10 ) {//待审查之后状态才显示
            this.showEvaluation = false
          }
          if( response.data != undefined ) {
            console.log(response.data)
             if( this.projectStatus == 18 && response.data >=10){
               this.showEvaluation = false
            }
            
          }
        })
        .catch(() => {
        })
    },
    createData(){
        this.dataForm.houseList.forEach((item,index) => {
          if( item.addressRegionValues.length>0){
            item.provinceId = item.addressRegionValues[0]
            item.cityId = item.addressRegionValues[1]
            item.areaId = item.addressRegionValues[2]
          }
          for(let i=0;i<item.editForm.length;i++) {
            let items = item.editForm[i]
             if (items.slEvaluationPrice!=undefined && parseFloat(items.slEvaluationPrice).toString() == "NaN") {
                items.slEvaluationPrice = undefined
            }else{
              items.slEvaluationPrice = items.slEvaluationPrice
            }
          }

          
         item.rate = item.editForm.rate
         item.taskId = this.taskId
         item.houseEvaluateDTO = item.editForm
        })
        
      
        
        updateHouse(this.dataForm.houseList)
            .then(response => {
              this.findByProjectId()
              this.$notify.success({
                title: '成功',
                message: '保存成功'
              })
              capitalMatch({projectId:this.projectId}).then(res => {
                if(res.data) {
                  this.$emit('getCapital');
                  this.$emit("getCapitalTrue")
                }else{
                  this.$notify.error({
                    title: '失败',
                    message: '资方更新失败'
                  })
                }
              }).catch(() => {
                this.$notify.error({
                    title: '失败',
                    message: '资方更新失败'
                  })
              })
            })
            .catch(response => {
            })
    },
    clickGet(index){ 
      console.log(this.dataForm.houseList[index])
       if( this.dataForm.houseList[index].regionValues === undefined || this.dataForm.houseList[index].regionValues.length===0 ) {
         this.$message.error("请先选择区域哦")
         return false
       }
       if( this.dataForm.houseList[index].areaTotal == undefined || this.dataForm.houseList[index].areaTotal==0){
         this.$message.info("请填写房产建筑面积")
         return false
       }
       this.houseEvaluation(index)
    },
    exportData() {

        exportHouse({projectId: this.projectId})
            .then((res) => {
              const content = res.data;
              
              window.open(content.fileUrl)
            })
            .catch(response => {
              console.log(response)
              this.$notify.error({
                title: '失败',
                message: response.data.message
              })
            })
      },
      //利用函数传参达到复用，以减少代码量
      numValid(val,index){
        //只能输入数字
        // this.editForm[val] = this.editForm[val].replace(/(^\s*)|(\s*$)/g, "");
        const reg = /[^\d.]/g;

        // 只能是数字和小数点，不能是其他输入
        this.dataForm.houseList[index].editForm[val] = this.dataForm.houseList[index].editForm[val].replace(reg, "");

        // 保证第一位只能是数字，不能是点
        this.dataForm.houseList[index].editForm[val] = this.dataForm.houseList[index].editForm[val].replace(/^\./g, "");
        // 小数只能出现1位
        this.dataForm.houseList[index].editForm[val] = this.dataForm.houseList[index].editForm[val]
          .replace(".", "$#$")
          .replace(/\./g, "")
          .replace("$#$", ".");
        // 小数点后面保留2位
        this.dataForm.houseList[index].editForm[val] = this.dataForm.houseList[index].editForm[val].replace(
          /^(\-)*(\d+)\.(\d\d).*$/,
          "$1$2.$3"
        );
      },
      //利用函数传参达到复用，以减少代码量
      numValiddata(val,index){
        //只能输入数字
        // this.dataForm.houseList[index].editForm[val] = this.dataForm.houseList[index].editForm[val].replace(/(^\s*)|(\s*$)/g, "");
        const reg = /[^\d.]/g;

        // 只能是数字和小数点，不能是其他输入
        this.dataForm.houseList[index][val] = this.dataForm.houseList[index][val].replace(reg, "");

        // 保证第一位只能是数字，不能是点
        this.dataForm.houseList[index][val] = this.dataForm.houseList[index][val].replace(/^\./g, "");
        // 小数只能出现1位
        this.dataForm.houseList[index][val] = this.dataForm.houseList[index][val]
          .replace(".", "$#$")
          .replace(/\./g, "")
          .replace("$#$", ".");
        // 小数点后面保留2位
        this.dataForm.houseList[index][val] = this.dataForm.houseList[index][val].replace(
          /^(\-)*(\d+)\.(\d\d).*$/,
          "$1$2.$3"
        );
      },
      inputChange(value,type,index) {
        let slEvaluationPrice = this.dataForm.houseList[index].editForm.slEvaluationPrice;
        // (世联评估价-当前输入项值）/世联评估价*100
        if(type == 'slEvaluationPrice'){
          //蓝海
          if(this.dataForm.houseList[index].editForm.lanhaiEvaluationPrice != "" || this.dataForm.houseList[index].editForm.lanhaiEvaluationPrice != undefined ) {
            let tb = (this.dataForm.houseList[index].editForm.lanhaiEvaluationPrice - slEvaluationPrice)/slEvaluationPrice*100;
          // tb = !isNaN(tb) && tb<0?Number(tb.toString().replace(/-/g,'')):tb;
            this.dataForm.houseList[index].editForm.lanhaiRate = !isNaN(tb)?tb.toFixed(2):'';
          }
          //国厚
          if(this.dataForm.houseList[index].editForm.guohouEvaluationPrice != "" || this.dataForm.houseList[index].editForm.guohouEvaluationPrice  != undefined ) {
            let tb = (this.dataForm.houseList[index].editForm.guohouEvaluationPrice - slEvaluationPrice)/slEvaluationPrice*100;
          // tb = !isNaN(tb) && tb<0?Number(tb.toString().replace(/-/g,'')):tb;
            this.dataForm.houseList[index].editForm.guohouRate = !isNaN(tb)?tb.toFixed(2):'';
             
          }
          //小忆
          if(this.dataForm.houseList[index].editForm.xiaoyiEvaluationPrice != "" || this.dataForm.houseList[index].editForm.xiaoyiEvaluationPrice != undefined ) {
            let tb = (this.dataForm.houseList[index].editForm.xiaoyiEvaluationPrice - slEvaluationPrice)/slEvaluationPrice*100;
          // tb = !isNaN(tb) && tb<0?Number(tb.toString().replace(/-/g,'')):tb;
            this.dataForm.houseList[index].editForm.xiaoyiRate = !isNaN(tb)?tb.toFixed(2):'';
          }
          //亚联财
          if(this.dataForm.houseList[index].editForm.yaliancaiEvaluationPrice != "" || this.dataForm.houseList[index].editForm.yaliancaiEvaluationPrice != undefined ) {
            let tb = (this.dataForm.houseList[index].editForm.yaliancaiEvaluationPrice - slEvaluationPrice)/slEvaluationPrice*100;
          // tb = !isNaN(tb) && tb<0?Number(tb.toString().replace(/-/g,'')):tb;
            this.dataForm.houseList[index].editForm.yaliancaiRate = !isNaN(tb)?tb.toFixed(2):'';
          }
          //中关村
          if(this.dataForm.houseList[index].editForm.zhongguancunEvaluationPrice != "" || this.dataForm.houseList[index].editForm.zhongguancunEvaluationPrice != undefined ) {
            let tb = (this.dataForm.houseList[index].editForm.zhongguancunEvaluationPrice - slEvaluationPrice)/slEvaluationPrice*100;
          // tb = !isNaN(tb) && tb<0?Number(tb.toString().replace(/-/g,'')):tb;
            this.dataForm.houseList[index].editForm.zhongguancunRate = !isNaN(tb)?tb.toFixed(2):'';
          }
          //其他
          if(this.dataForm.houseList[index].editForm.otherEvaluationPrice != "" || this.dataForm.houseList[index].editForm.otherEvaluationPrice != undefined ) {
            let tb = (this.dataForm.houseList[index].editForm.otherEvaluationPrice - slEvaluationPrice)/slEvaluationPrice*100;
          // tb = !isNaN(tb) && tb<0?Number(tb.toString().replace(/-/g,'')):tb;
            this.dataForm.houseList[index].editForm.otherRate = !isNaN(tb)?tb.toFixed(2):'';
          }
        }else{
          if(slEvaluationPrice && slEvaluationPrice != ""){
            let tb = (value - slEvaluationPrice)/slEvaluationPrice*100;
            // tb = !isNaN(tb) && tb<0?Number(tb.toString().replace(/-/g,'')):tb;
            this.dataForm.houseList[index].editForm[type] = !isNaN(tb) && value != ''?tb.toFixed(2):'';
          }
        }
        this.$forceUpdate()
      }
    }
  }
</script>

<style>

.table_1 .el-input__inner{
  height:52px;
  line-height: 55px;
  border:0px solid;
}

.table_1 .el-input-group__append{
  border:0px solid;
}
.table_2 .el-input__inner:hover{
  border-color:#C0C4CC;
}

.table_1 .box-card{
  margin-top:30px;
  background-color: #f4f4f4;
}
.table_1 .box-card .el-form-item__content{
  width: 400px;
}

.table_1 {
  background-color: #fff;
  width: 100%;
  font-size: 14px;
}
.table_title{
  background-color: #fff;
  border-top: 1px solid #c7c7c7;
  border-right: 1px solid #c7c7c7;
  border-left: 1px solid #c7c7c7;
  width: 100%;
  background-color: #fff;
  text-align: center;
  line-height: 50px;
}
.table_wrap{
  border-collapse: collapse;
  border-spacing: 0px;
  width: 100%;

}

.table_td {
  text-align: center;
  line-height: 50px;
  min-width: 90px;
  border: 1px solid #c7c7c7;
}
.td_color{
  background-color: #f4f4f4;
}

</style>